package gredis

import (
	"encoding"
	"fmt"
)

type Serializable interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

type BaseRedisClient interface {
	fmt.Stringer
	Execute(cmd string, args ...interface{}) (interface{}, error)
	Set(key string, data interface{}, timeoutSeconds int) error
	Get(key string, result interface{}) error
	Delete(keys ...string) error
	Exists(key string) (bool, error)
	Expire(key string, timeoutSeconds int) error
	// GetExpire
	// 当 key 不存在时，返回 -2 。
	// 当 key 存在但没有设置剩余生存时间时，返回 -1 。
	// 当查询报错时，返回-3
	// 否则，以秒为单位，返回 key 的剩余生存时间。
	GetExpire(key string) (int64, error)
	SetHash(key, hKey string, data interface{}, timeoutSeconds int) error
	GetHash(key, hKey string, result interface{}) error
	DeleteHash(key, hKey string) error
	GetHashAll(key string) ([]interface{}, error)
	GetLock(key, token string, timeoutSeconds int) (bool, error)
	UnLock(key, token string) (bool, error)
}
